package com.yuxi;

/**
 * yeild 高风亮节让出cup
 * Created by yuxi on 17/1/27.
 */
public class YeildDemo {
    public static void main(String[] args) {
        MyThread myThread = new MyThread();
        new Thread(myThread).start();
        new Thread(myThread).start();

    }

    static class MyThread implements Runnable {
        public synchronized void run() {
            for (int i = 0; i < 100; i++) {
                if (i % 4 == 0) {
                    Thread.yield();
                } else {
                    System.out.println("当前线程为。。。。" + Thread.currentThread().getName());
                }


            }
        }

    }
}
